package junit.com.cpi.cornpp.user.services;

import junit.framework.TestCase;

import com.cpi.cornpp.user.exception.UserException;
import com.cpi.cornpp.user.services.UserServices;
import com.cpi.cornpp.user.view.UserView;

/**
 * UserServicesTest
 * @author Edgar Joao
 *
 */
public class UserServicesTest extends TestCase {

	/**UserServices */
	UserServices userServices = null;
	/**UserView */
	UserView userView = null;
	/**Valid User */
	private static final String VALID_USER = "jrivas";
	/**Valid Password */
	private static final String VALID_PASSWORD = "clodoaldo";
	
	public UserServicesTest(String name) {
		super(name);
	}

	protected void setUp() throws Exception {
		super.setUp();
		userServices = new UserServices();
		userView = new UserView();
	}

	protected void tearDown() throws Exception {
		super.tearDown();
	}

	public void testLoginUser() {
		
		userView.setUsrId(VALID_USER);
		userView.setPassword(VALID_PASSWORD);
		
		try {			
			System.out.println(userServices.loginUser(userView).getNombre());
			assertTrue(userServices.loginUser(userView).getNombre().length() > 0);
		} catch (UserException e) {
			fail(e.getMessage());	
		}
				
	}

}
